package fr.esiag.isidis.fi.pdsTeam.tram;

import fr.esiag.isidis.fi.pdsTeam.events.MyEvent;



public class Marshaller {
	static Marshaller instance = null;
	
	private Marshaller() {

	}
	
	public static Marshaller getInstance() {
		if (instance == null)
			instance = new Marshaller();
		return instance;
	}
	
	public byte[] marsahllEvent(MyEvent event){
		byte[]mac = event.getSensorMacAddress().getBytes();
		
		byte[] tram = new byte[mac.length+2];
		tram[0] = (byte)event.getEventCode();
		tram[1] = (byte)event.getSensorMacAddress().length();
		for (int i = 0; i < mac.length; i++) {
			tram[i+2] = mac[i];
		}
		return tram;
	}
}
